﻿<?php
	echo $_POST['username'];
	include("MySQL.php");
	if(isset($_POST['btn_login'])) {
            $loginID=$_POST['username'];
            $loginPass=$_POST['userpass'];
            $_userfound_ = FALSE;$_passright_=FALSE;
			
            mysql_select_db("mydata", $MySQL);
            $sql="SELECT * FROM users WHERE user_login='".$loginID."'";
            $result=  mysql_query($sql, $MySQL);
            while($row = mysql_fetch_array($result)){
                if($row['user_login'] == $loginID && $row['user_pass'] == $loginPass) {
                    $_userfound_ = TRUE; $_passright_=TRUE;
                    break;
                }
                }
            if($_userfound_ && $_passright_) {
                $_SESSION["userid"]=$loginID;
                echo "欢迎您！亲爱的{$loginID}!";
                $url = "logedin.php";
                echo "<script language='javascript' type='text/javascript'>";
                echo "window.location.href='$url'";
                echo "</script>";

            } else {
                $_SESSION["userid"]="Guest";
                echo "用户名或密码错误！请输入正确的用户名和密码！";
                }
            }
?>